<template>
	<view class="container">
		<block>
			<!-- s -->
			<view style="width:100%;height: 100%;">
				<view style="text-align: center;margin-top: 30rpx;">
					<img :src="logo" style="height: 400rpx;" mode="aspectFit">
					<!-- <view class="title">
						师傅协议须知
					</view> -->
				</view>

				<view class="content_div1">
					<view class="card_div1" :style="'background:#FFFFFF'">

						<view @tap="isagreeChange" class="xycss1">
							<checkbox-group style="display: inline-block;">
								<checkbox style="transform: scale(0.6)" value="1" :checked="isagree" />
								<text :style="'color:#D8D8D8'">我已阅读并同意</text>
							</checkbox-group>
							<text @tap="showxieyiFun2" :style="'color:#E64340'">{{xyname2}}</text>
						</view>

						<view style="margin-top: 40rpx;">
							<block>
								<button @tap="authlogin" class="btn1"
									:style="'background:rgba('+t('color1rgb')+');color: #FFFFFF'">
									<block>
										同意并实名认证
									</block>
								</button>
							</block>

							<button class="btn1" @tap="goback"
								style="background-color:#EEEEEE ;font-size: 28rpx;">不同意</button>

						</view>
					</view>
				</view>
			</view>
			<!-- e -->

			<view v-if="showxieyi2" class="xieyibox">
				<view class="xieyibox-content">
					<view style="overflow:scroll;height:100%;">
						<parse :content="xycontent2" @navigate="navigate"></parse>
					</view>
					<view
						style="position:absolute;z-index:9999;bottom:10px;left:0;right:0;margin:0 auto;text-align:center; width: 50%;height: 60rpx; line-height: 60rpx; color: #fff; border-radius: 8rpx;"
						:style="{background:'linear-gradient(90deg,'+t('color1')+' 0%,rgba('+t('color1rgb')+',0.8) 100%)'}"
						@tap="hidexieyi2">已阅读并同意</view>
				</view>
			</view>

		</block>
	</view>
</template>

<script>
	var app = getApp();

	export default {
		data() {
			return {
				opt: {},
				logo: '',
				name: '',
				xyname2: '',
				xycontent2: '',
				showxieyi2: false,
				isagree: false,
				mid: 0,
				is_run: 1
			};
		},

		onLoad: function(opt) {
			this.opt = app.getopts(opt);
			if (opt.is_run == 0) {
				this.is_run = 0;
			}
			this.getdata();
		},
		onShow: function() {},
		onPullDownRefresh: function() {

		},
		methods: {
			getdata: function() {
				var that = this;
				app.post("ApiMy/inspect_worker", {}, function(res) {
					if (res.code == 0) {
						app.alert(res.msg);
						setTimeout(function() {
							app.goto("/pages/my/usercenter", "reLaunch");
						}, 1000);
					} else if (res.code == 1 && that.is_run) {
						app.goto("/activity/yuyue/dating", "reLaunch");
					} else if (res.code == 2) {
						app.alert(res.msg);
						setTimeout(function() {
							app.goto("/pages/index/login?logintype=4", "reLaunch");
						}, 1000);
					} else if (res.code == -1) {
						var mid = res.id;
						app.confirm(res.msg, function() {
							app.showLoading('提交中');
							app.post('ApiMy/inspect_worker', {
								mid: mid
							}, function(data) {
								if (data.status == 1) {
									app.alert(data.msg);
									setTimeout(function() {
										app.goto("/pages/my/usercenter", "reLaunch");
									}, 1000);
								} else {
									app.alert(data.msg);
									setTimeout(function() {
										app.goto("/pages/my/usercenter", "reLaunch");
									}, 1000);

								}
							});
						}, function() {
							app.goto("/pages/my/usercenter", "reLaunch");
						});

					} else {
						that.xyname2 = res.xyname2;
						that.xycontent2 = res.xycontent2;
						that.logo = res.logo;
						that.name = res.name;
						that.tel = res.tel;
						if (!res.tel) {
							app.alert("电话号码未绑定");
							setTimeout(function() {
								app.goto("/pages/my/usercenter", "reLaunch");
							}, 1000);
						}
						that.mid = res.id;
						that.loaded();
					}
				});
			},

			goback: function() {
				app.goto('/pages/my/usercenter', 'reLaunch');
			},

			authlogin: function(e) {
				var that = this;
				if (!that.isagree) {
					app.error('请先阅读并同意' + that.xyname2);
					return false;
				}
				app.goto('authentication?mid=' + that.mid);
			},

			isagreeChange: function(e) {
				if (this.isagree) {
					this.isagree = false;
				} else {
					this.isagree = true;
					// this.showxieyi2 = true;
				}
				console.log(this.isagree);
			},
			showxieyiFun2: function() {
				this.showxieyi2 = true;
			},
			hidexieyi2: function() {
				this.showxieyi2 = false;
				this.isagree = true;
			},


		}
	};
</script>

<style>
	page {
		background: #ffffff;
		width: 100%;
		height: 100%;
	}

	.container {
		width: 100%;
		height: 100%;
	}

	.text-center {
		text-align: center;
	}

	.xieyi-item {
		display: flex;
		align-items: center;
		margin-top: 30rpx
	}

	.xieyi-item {
		font-size: 24rpx;
		color: #B2B5BE
	}

	.xieyi-item .checkbox {
		transform: scale(0.6);
	}

	.authlogin {
		display: flex;
		flex-direction: column;
		align-items: center
	}

	.authlogin-logo {
		width: 180rpx;
		height: 180rpx;
		margin-top: 120rpx
	}

	.authlogin-name {
		color: #999999;
		font-size: 30rpx;
		margin-top: 60rpx;
	}

	.authlogin-btn {
		width: 580rpx;
		height: 96rpx;
		line-height: 96rpx;
		background: #51B1F5;
		border-radius: 48rpx;
		color: #fff;
		margin-top: 100rpx
	}

	.authlogin-btn2 {
		width: 580rpx;
		height: 96rpx;
		line-height: 96rpx;
		background: #EEEEEE;
		border-radius: 48rpx;
		color: #A9A9A9;
		margin-top: 20rpx
	}




	.xieyibox {
		width: 100%;
		height: 100%;
		position: fixed;
		top: 0;
		left: 0;
		z-index: 99;
		background: rgba(0, 0, 0, 0.7)
	}

	.xieyibox-content {
		width: 90%;
		margin: 0 auto;
		/*  #ifdef  MP-TOUTIAO */
		height: 60%;
		/*  #endif  */
		/*  #ifndef  MP-TOUTIAO */
		height: 80%;
		/*  #endif  */
		margin-top: 20%;
		background: #fff;
		color: #333;
		padding: 5px 10px 50px 10px;
		position: relative;
		border-radius: 2px;
	}



	.content_div1 {
		width: 700rpx;
		margin: 0 auto;
		margin-bottom: 60rpx;
	}

	.card_div1 {
		width: 100%;
		padding: 40rpx;
		border-radius: 24rpx;
		margin-top: 40rpx;
	}


	.btn1 {
		width: 100%;
		height: 100rpx;
		border-radius: 100rpx;
		line-height: 100rpx;
		margin: 20rpx 0;
		text-align: center;
		font-weight: bold;
		color: #A9A9A9;
		font-size: 30rpx
	}

	.title {
		text-align: center;
		opacity: 1;
		font-size: 40rpx;
		font-weight: bold;
	}





	.xycss1 {
		line-height: 60rpx;
		font-size: 30rpx;
		overflow: hidden;
	}
</style>